tpluspy 0.6.0__tar.gz → 0.8.0__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.
Files changed (182) hide show
  1. {tpluspy-0.6.0 → tpluspy-0.8.0}/PKG-INFO +3 -3
  2. {tpluspy-0.6.0 → tpluspy-0.8.0}/setup.py +3 -3
  3. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/__init__.py +2 -0
  4. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/assets.py +139 -17
  5. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/env.py +5 -0
  6. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/markets.py +32 -14
  7. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/orders.py +14 -10
  8. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/params.py +22 -7
  9. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/vaults.py +192 -103
  10. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/withdraw.py +12 -11
  11. tpluspy-0.8.0/tplus/_cli/withdrawal.py +151 -0
  12. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/cli_tools/__init__.py +17 -1
  13. tpluspy-0.8.0/tplus/cli_tools/options.py +191 -0
  14. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/cli_tools/output.py +9 -0
  15. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/api.py +6 -0
  16. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/auth.py +49 -7
  17. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/base.py +16 -1
  18. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/clearingengine/__init__.py +12 -0
  19. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/clearingengine/admin.py +189 -22
  20. tpluspy-0.8.0/tplus/client/clearingengine/admin_settlement.py +44 -0
  21. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/clearingengine/assetregistry.py +6 -13
  22. tpluspy-0.8.0/tplus/client/clearingengine/cross_venue.py +80 -0
  23. tpluspy-0.8.0/tplus/client/clearingengine/fee_accounts.py +108 -0
  24. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/clearingengine/vault.py +10 -7
  25. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/market_data.py +20 -0
  26. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/oms/assetregistry.py +15 -2
  27. tpluspy-0.8.0/tplus/client/oms/oms_admin.py +174 -0
  28. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/orderbook.py +494 -63
  29. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/withdrawal.py +21 -9
  30. tpluspy-0.8.0/tplus/evm/backends/_ape_project.py +123 -0
  31. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/backends/ape.py +8 -0
  32. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/backends/base.py +4 -0
  33. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/backends/web3.py +10 -0
  34. tpluspy-0.8.0/tplus/evm/contracts.py +1644 -0
  35. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/dev/env.py +54 -43
  36. tpluspy-0.8.0/tplus/evm/governance.py +578 -0
  37. tpluspy-0.8.0/tplus/evm/managers/credential_manager.py +154 -0
  38. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/registry.py +31 -20
  39. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/settle.py +22 -15
  40. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/vault.py +4 -31
  41. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/withdraw.py +129 -76
  42. tpluspy-0.8.0/tplus/evm/manifests/tplus-contracts.json +1 -0
  43. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/mocks/RepresentationRateMocks.sol +16 -10
  44. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/mocks/representation_rate_mocks.json +1 -1
  45. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/exceptions.py +11 -0
  46. tpluspy-0.8.0/tplus/model/approval.py +48 -0
  47. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/batch_order.py +66 -0
  48. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/cancel_order.py +3 -4
  49. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/config.py +36 -0
  50. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/control.py +29 -0
  51. tpluspy-0.8.0/tplus/model/conversion.py +14 -0
  52. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/interest_rates.py +1 -1
  53. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/market.py +38 -13
  54. tpluspy-0.8.0/tplus/model/multisig.py +64 -0
  55. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/order.py +40 -4
  56. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/orderbook.py +6 -0
  57. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/position.py +5 -0
  58. tpluspy-0.8.0/tplus/model/registry_asset.py +38 -0
  59. tpluspy-0.8.0/tplus/model/representation_rate.py +148 -0
  60. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/risk_parameters.py +5 -0
  61. tpluspy-0.8.0/tplus/model/settlement.py +198 -0
  62. tpluspy-0.8.0/tplus/model/sync_book.py +24 -0
  63. tpluspy-0.8.0/tplus/model/sync_order.py +139 -0
  64. tpluspy-0.8.0/tplus/model/sync_settlement.py +96 -0
  65. tpluspy-0.8.0/tplus/model/transfer.py +11 -0
  66. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/types.py +12 -0
  67. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/user_event.py +119 -7
  68. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/user_inventory.py +6 -3
  69. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/user_margin.py +22 -0
  70. tpluspy-0.8.0/tplus/model/vault.py +28 -0
  71. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/withdrawal.py +84 -13
  72. tpluspy-0.8.0/tplus/utils/amend_order.py +43 -0
  73. tpluspy-0.8.0/tplus/utils/limit_order.py +170 -0
  74. tpluspy-0.8.0/tplus/utils/signing.py +18 -0
  75. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/timeout.py +26 -3
  76. tpluspy-0.8.0/tplus/utils/universe.py +28 -0
  77. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/manager.py +2 -2
  78. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/model.py +6 -6
  79. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/PKG-INFO +3 -3
  80. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/SOURCES.txt +11 -0
  81. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/requires.txt +2 -2
  82. tpluspy-0.6.0/tplus/_cli/withdrawal.py +0 -118
  83. tpluspy-0.6.0/tplus/cli_tools/options.py +0 -91
  84. tpluspy-0.6.0/tplus/client/clearingengine/admin_settlement.py +0 -35
  85. tpluspy-0.6.0/tplus/client/clearingengine/cross_venue.py +0 -44
  86. tpluspy-0.6.0/tplus/client/oms/oms_admin.py +0 -91
  87. tpluspy-0.6.0/tplus/evm/backends/_ape_project.py +0 -78
  88. tpluspy-0.6.0/tplus/evm/contracts.py +0 -938
  89. tpluspy-0.6.0/tplus/evm/managers/credential_manager.py +0 -201
  90. tpluspy-0.6.0/tplus/evm/manifests/tplus-contracts.json +0 -1
  91. tpluspy-0.6.0/tplus/model/approval.py +0 -12
  92. tpluspy-0.6.0/tplus/model/multisig.py +0 -38
  93. tpluspy-0.6.0/tplus/model/representation_rate.py +0 -109
  94. tpluspy-0.6.0/tplus/model/settlement.py +0 -384
  95. tpluspy-0.6.0/tplus/utils/limit_order.py +0 -69
  96. tpluspy-0.6.0/tplus/utils/signing.py +0 -36
  97. {tpluspy-0.6.0 → tpluspy-0.8.0}/README.md +0 -0
  98. {tpluspy-0.6.0 → tpluspy-0.8.0}/pyproject.toml +0 -0
  99. {tpluspy-0.6.0 → tpluspy-0.8.0}/setup.cfg +0 -0
  100. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/__init__.py +0 -0
  101. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/__main__.py +0 -0
  102. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/_context.py +0 -0
  103. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/accounts.py +0 -0
  104. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/balance.py +0 -0
  105. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/debug.py +0 -0
  106. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/decimals.py +0 -0
  107. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/deposit.py +0 -0
  108. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/settle.py +0 -0
  109. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/sign.py +0 -0
  110. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/stream.py +0 -0
  111. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/_cli/trades.py +0 -0
  112. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/asset_metadata.py +0 -0
  113. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/__init__.py +0 -0
  114. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/blockchain.py +0 -0
  115. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/clearingengine/base.py +0 -0
  116. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/oms/__init__.py +0 -0
  117. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/client/websocket.py +0 -0
  118. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/constants.py +0 -0
  119. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/__init__.py +0 -0
  120. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/_manifest.py +0 -0
  121. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/abi.py +0 -0
  122. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/address.py +0 -0
  123. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/backends/__init__.py +0 -0
  124. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/constants.py +0 -0
  125. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/dev/__init__.py +0 -0
  126. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/dev/contracts.py +0 -0
  127. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/dev/token.py +0 -0
  128. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/exceptions.py +0 -0
  129. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/__init__.py +0 -0
  130. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/chaindata.py +0 -0
  131. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/deposit.py +0 -0
  132. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/managers/evm.py +0 -0
  133. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/mocks/__init__.py +0 -0
  134. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/evm/utils.py +0 -0
  135. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/logger.py +0 -0
  136. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/managers/__init__.py +0 -0
  137. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/managers/base.py +0 -0
  138. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/__init__.py +0 -0
  139. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/asset_identifier.py +0 -0
  140. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/auth.py +0 -0
  141. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/chain_address.py +0 -0
  142. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/close_all_positions_preview.py +0 -0
  143. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/council.py +0 -0
  144. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/intent.py +0 -0
  145. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/klines.py +0 -0
  146. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/limit_order.py +0 -0
  147. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/market_order.py +0 -0
  148. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/open_interest.py +0 -0
  149. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/order_id.py +0 -0
  150. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/order_trigger.py +0 -0
  151. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/pagination.py +0 -0
  152. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/position_basis.py +0 -0
  153. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/replace_order.py +0 -0
  154. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/signed_message.py +0 -0
  155. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/sub_account.py +0 -0
  156. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/ticker.py +0 -0
  157. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/trades.py +0 -0
  158. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/user_simulated_margin.py +0 -0
  159. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/model/user_solvency.py +0 -0
  160. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/py.typed +0 -0
  161. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/types.py +0 -0
  162. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/__init__.py +0 -0
  163. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/address.py +0 -0
  164. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/amount.py +0 -0
  165. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/bytes32.py +0 -0
  166. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/decimals.py +0 -0
  167. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/domain.py +0 -0
  168. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/hex.py +0 -0
  169. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/market_order.py +0 -0
  170. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/operator.py +0 -0
  171. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/replace_order.py +0 -0
  172. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/serializers.py +0 -0
  173. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/__init__.py +0 -0
  174. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/decrypt.py +0 -0
  175. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/ed_keyfile.py +0 -0
  176. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/evm.py +0 -0
  177. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/token_cache.py +0 -0
  178. {tpluspy-0.6.0 → tpluspy-0.8.0}/tplus/utils/user/validate.py +0 -0
  179. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/dependency_links.txt +0 -0
  180. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/entry_points.txt +0 -0
  181. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/not-zip-safe +0 -0
  182. {tpluspy-0.6.0 → tpluspy-0.8.0}/tpluspy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tpluspy
3
- Version: 0.6.0
3
+ Version: 0.8.0
4
4
  Summary: tpluspy: Client utilities for interacting with tplus
5
5
  Home-page: https://github.com/tpluslabs/tpluspy
6
6
  Author: TPlus Labs
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Requires-Python: >=3.10,<4
22
22
  Description-Content-Type: text/markdown
23
+ Requires-Dist: anyio>=4
23
24
  Requires-Dist: click>=8.1
24
25
  Requires-Dist: cryptography>=44.0.1
25
26
  Requires-Dist: eth-pydantic-types<0.3,>=0.2.6
@@ -34,7 +35,6 @@ Requires-Dist: pytest>=8.0; extra == "test"
34
35
  Requires-Dist: pytest-timeout<3,>=2.2.0; extra == "test"
35
36
  Requires-Dist: pytest-mock; extra == "test"
36
37
  Requires-Dist: pytest-asyncio; extra == "test"
37
- Requires-Dist: anyio>=4; extra == "test"
38
38
  Requires-Dist: pytest-anyio>=0.0.0; extra == "test"
39
39
  Requires-Dist: trio>=0.24; extra == "test"
40
40
  Requires-Dist: eth-tester[py-evm]>=0.12.0b1; extra == "test"
@@ -47,7 +47,7 @@ Requires-Dist: wheel; extra == "release"
47
47
  Requires-Dist: twine; extra == "release"
48
48
  Provides-Extra: evm
49
49
  Requires-Dist: click; extra == "evm"
50
- Requires-Dist: eip712>=0.3.1; extra == "evm"
50
+ Requires-Dist: eip712>=0.3.2; extra == "evm"
51
51
  Requires-Dist: eth-account<0.14,>=0.13.0; extra == "evm"
52
52
  Requires-Dist: eth-keys<0.8,>=0.6; extra == "evm"
53
53
  Requires-Dist: hexbytes<2,>=1.3.1; extra == "evm"
@@ -8,7 +8,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
8
8
 
9
9
  setup(
10
10
  name="tpluspy",
11
- version="0.6.0",
11
+ version="0.8.0",
12
12
  description="""tpluspy: Client utilities for interacting with tplus""",
13
13
  long_description=long_description,
14
14
  long_description_content_type="text/markdown",
@@ -17,6 +17,7 @@ setup(
17
17
  url="https://github.com/tpluslabs/tpluspy",
18
18
  include_package_data=True,
19
19
  install_requires=[
20
+ "anyio>=4",
20
21
  "click>=8.1",
21
22
  "cryptography>=44.0.1",
22
23
  "eth-pydantic-types>=0.2.6,<0.3",
@@ -39,7 +40,6 @@ setup(
39
40
  "pytest-timeout>=2.2.0,<3",
40
41
  "pytest-mock",
41
42
  "pytest-asyncio",
42
- "anyio>=4",
43
43
  "pytest-anyio>=0.0.0",
44
44
  "trio>=0.24",
45
45
  # In-process EVM backend used by the web3-backend tests. ``py-evm``
@@ -58,7 +58,7 @@ setup(
58
58
  ],
59
59
  "evm": [
60
60
  "click",
61
- "eip712>=0.3.1",
61
+ "eip712>=0.3.2",
62
62
  "eth-account>=0.13.0,<0.14",
63
63
  "eth-keys>=0.6,<0.8",
64
64
  "hexbytes>=1.3.1,<2",
@@ -1,5 +1,6 @@
1
1
  from tplus.client import TplusApiClient
2
2
  from tplus.exceptions import (
3
+ AssetDecimalsUnavailable,
3
4
  AuthError,
4
5
  NotFoundError,
5
6
  OmsError,
@@ -10,6 +11,7 @@ from tplus.exceptions import (
10
11
  )
11
12
 
12
13
  __all__ = [
14
+ "AssetDecimalsUnavailable",
13
15
  "AuthError",
14
16
  "NotFoundError",
15
17
  "OmsError",
@@ -12,16 +12,24 @@ from tplus._cli._context import (
12
12
  tplus_account_option,
13
13
  )
14
14
  from tplus.cli_tools import (
15
+ asset_data_options,
15
16
  chain_address_record,
17
+ describe_schedule_event,
16
18
  echo_with_pager,
17
19
  ignore_ssl_option,
18
20
  no_pager_option,
21
+ op_id_option,
19
22
  output_format_option,
20
23
  registry_address_option,
21
24
  render,
25
+ resolve_universe,
26
+ universe_option,
22
27
  )
28
+ from tplus.utils.universe import compute_universe_id
23
29
 
24
30
  if TYPE_CHECKING:
31
+ from collections.abc import Iterable
32
+
25
33
  from eth_pydantic_types.address import AddressType
26
34
 
27
35
  from tplus.evm.contracts import Registry
@@ -175,21 +183,55 @@ if _EVM_AVAILABLE:
175
183
  registry = cast("Registry", Registry.at(registry_address)) if registry_address else None
176
184
  return RegistryOwner(owner=signer, registry=registry, clearing_engine=ce)
177
185
 
178
- @assets.command("set-risk-manager", cls=ConnectedProviderCommand)
186
+ @assets.command("init-risk-council", cls=ConnectedProviderCommand)
179
187
  @tplus_network_option()
180
188
  @clearing_url_option()
181
189
  @ignore_ssl_option()
182
190
  @registry_address_option()
183
191
  @tplus_account_option()
184
192
  @account_option()
185
- @click.argument("multisig")
193
+ @click.argument("credential_manager")
194
+ @universe_option(
195
+ help="Governance universe of CREDENTIAL_MANAGER. Required off the local network."
196
+ )
197
+ @click.option(
198
+ "--member",
199
+ "members",
200
+ multiple=True,
201
+ help="Risk council member address. May be repeated. Defaults to the sender.",
202
+ )
203
+ @click.option("--threshold", type=int, help="Defaults to a strict majority of the members.")
186
204
  @pass_cli_context
187
- def _set_risk_manager(
188
- cli_ctx: CLIContext, account, multisig: str, registry_address: str | None
205
+ def _init_risk_council(
206
+ cli_ctx: CLIContext,
207
+ account,
208
+ credential_manager: str,
209
+ universe: str | None,
210
+ members: "Iterable[str]",
211
+ threshold: int | None,
212
+ registry_address: str | None,
213
+ provider,
189
214
  ):
190
- """Set the Registry's risk manager multisig to MULTISIG."""
215
+ """Install the Registry's risk council, governed by CREDENTIAL_MANAGER."""
216
+ from tplus.evm.contracts import ZERO_ADDRESS
217
+ from tplus.evm.governance import compute_majority_threshold
218
+
191
219
  owner = _build_owner(cli_ctx, account, registry_address=registry_address)
192
- receipt = owner.set_risk_manager_multisig(multisig)
220
+ if owner.registry.get_credential_manager() != ZERO_ADDRESS:
221
+ click.echo("risk council already installed")
222
+ return
223
+
224
+ universe_id = bytes(
225
+ compute_universe_id(resolve_universe(universe, provider.network.is_local))
226
+ )
227
+
228
+ council = list(members) or [account.address]
229
+ receipt = owner.initialize_risk_council(
230
+ credential_manager,
231
+ universe_id,
232
+ council,
233
+ threshold or compute_majority_threshold(len(council)),
234
+ )
193
235
  click.echo(f"tx: {receipt.txn_hash}")
194
236
 
195
237
  @assets.command("deploy-registry", cls=ConnectedProviderCommand)
@@ -203,20 +245,60 @@ if _EVM_AVAILABLE:
203
245
  show_default=True,
204
246
  help="Risk-param delay in seconds.",
205
247
  )
248
+ @click.option(
249
+ "--upgrade-delay",
250
+ "upgrade_delay",
251
+ type=int,
252
+ default=0,
253
+ show_default=True,
254
+ help=(
255
+ "Proxy upgrade delay in seconds. Mainnet needs a non-zero delay unless "
256
+ "--allow-zero-upgrade-delay is passed."
257
+ ),
258
+ )
259
+ @click.option(
260
+ "--allow-zero-upgrade-delay",
261
+ is_flag=True,
262
+ help=(
263
+ "Allow a zero upgrade delay on mainnet for bootstrap; raise it before relying on "
264
+ "the upgrade timelock."
265
+ ),
266
+ )
206
267
  @click.option(
207
268
  "--skip-if-deployed",
208
269
  is_flag=True,
209
270
  help="Reuse the CE-registered deployment on this chain if live.",
210
271
  )
211
- def _deploy_registry(account, risk_param_delay: int, skip_if_deployed: bool):
212
- """Deploy a new Registry."""
272
+ def _deploy_registry(
273
+ provider,
274
+ account,
275
+ risk_param_delay: int,
276
+ upgrade_delay: int,
277
+ allow_zero_upgrade_delay: bool,
278
+ skip_if_deployed: bool,
279
+ ):
280
+ """Deploy a new Registry behind an ERC1967 proxy."""
213
281
  from tplus.evm.contracts import Registry
214
282
 
215
283
  if skip_if_deployed and (adopted := Registry()._adopt_ce_deployment()):
216
284
  click.echo(f"reused: {adopted.address}")
217
285
  return
218
286
 
219
- instance = Registry.deploy(account, risk_param_delay, sender=account)
287
+ if provider.network.is_mainnet and upgrade_delay == 0:
288
+ if not allow_zero_upgrade_delay:
289
+ raise click.UsageError(
290
+ "Pass a non-zero --upgrade-delay on mainnet, or --allow-zero-upgrade-delay "
291
+ "for bootstrap; with a zero delay the admin can upgrade the Registry at once."
292
+ )
293
+
294
+ click.echo(
295
+ "The Registry starts with a zero upgrade delay; raise it before relying on the "
296
+ "upgrade timelock."
297
+ )
298
+
299
+ instance = Registry.deploy_proxy(
300
+ sender=account, risk_param_delay_secs=risk_param_delay, upgrade_delay_secs=upgrade_delay
301
+ )
220
302
  click.echo(f"deployed: {instance.address}")
221
303
 
222
304
  @assets.command("set", cls=ConnectedProviderCommand)
@@ -226,12 +308,7 @@ if _EVM_AVAILABLE:
226
308
  @registry_address_option()
227
309
  @tplus_account_option()
228
310
  @account_option()
229
- @click.argument("index", type=int)
230
- @click.argument("asset_address")
231
- @click.option("--chain-id", "chain_id", type=int, required=True)
232
- @click.option("--max-deposit", "max_deposit", type=int, required=True)
233
- @click.option("--max-1hr", "max_1hr_deposits", type=int, required=True)
234
- @click.option("--min-weight", "min_weight", type=int, required=True)
311
+ @asset_data_options()
235
312
  @click.option("--no-wait", is_flag=True, help="Don't wait for CE ingestion.")
236
313
  @pass_cli_context
237
314
  def _set(
@@ -247,10 +324,11 @@ if _EVM_AVAILABLE:
247
324
  registry_address: str | None,
248
325
  ):
249
326
  """Register asset INDEX at ASSET_ADDRESS."""
327
+ from tplus.evm.governance import is_operation_due
250
328
  from tplus.model.types import ChainID
251
329
 
252
330
  owner = _build_owner(cli_ctx, account, registry_address=registry_address)
253
- asyncio.run(
331
+ schedule_event = asyncio.run(
254
332
  owner.set_asset(
255
333
  index=index,
256
334
  asset_address=cast("AddressType", asset_address),
@@ -261,7 +339,51 @@ if _EVM_AVAILABLE:
261
339
  wait=not no_wait,
262
340
  )
263
341
  )
264
- click.echo(f"Asset {index} registered.")
342
+ if is_operation_due(schedule_event, owner.registry.backend):
343
+ click.echo(f"Asset {index} registered.")
344
+ else:
345
+ click.echo(f"Asset {index} {describe_schedule_event(schedule_event)}")
346
+
347
+ @assets.command("execute", cls=ConnectedProviderCommand)
348
+ @tplus_network_option()
349
+ @clearing_url_option()
350
+ @ignore_ssl_option()
351
+ @registry_address_option()
352
+ @tplus_account_option()
353
+ @account_option()
354
+ @asset_data_options()
355
+ @op_id_option()
356
+ @pass_cli_context
357
+ def _execute(
358
+ cli_ctx: CLIContext,
359
+ account,
360
+ index: int,
361
+ asset_address: str,
362
+ chain_id: int,
363
+ max_deposit: int,
364
+ max_1hr_deposits: int,
365
+ min_weight: int,
366
+ op_id: bytes,
367
+ registry_address: str | None,
368
+ ):
369
+ """Execute the asset entry scheduled for INDEX, then request CE ingestion."""
370
+ from tplus.evm.contracts import Registry
371
+ from tplus.model.types import ChainID
372
+
373
+ owner = _build_owner(cli_ctx, account, registry_address=registry_address)
374
+ data = Registry.build_asset_data(
375
+ index,
376
+ cast("AddressType", asset_address),
377
+ ChainID.evm(chain_id),
378
+ max_deposit,
379
+ max_1hr_deposits,
380
+ min_weight,
381
+ )
382
+ receipt = owner.execute_operation("ASSET_DATA", [data], op_id)
383
+ click.echo(f"tx: {receipt.txn_hash}")
384
+ if ce := owner.ce:
385
+ asyncio.run(ce.assets.update())
386
+ click.echo("CE asset update requested.")
265
387
 
266
388
  else:
267
389
 
@@ -44,6 +44,11 @@ def env(output_format: str):
44
44
  "~/tplus/tplus-contracts",
45
45
  "Path to a local tplus-contracts checkout.",
46
46
  ),
47
+ (
48
+ "TPLUS_CONTRACTS_ALLOW_INSTALL",
49
+ "false",
50
+ "Let Ape install a missing tplus-contracts dependency on load.",
51
+ ),
47
52
  ]
48
53
  records = [
49
54
  {
@@ -110,7 +110,6 @@ def _list(
110
110
  "isolated_only": market.isolated_only,
111
111
  "tick_size": market.tick_size,
112
112
  "min_order_size": market.min_order_size,
113
- "fee_account": fee_schedule.fee_account if fee_schedule else None,
114
113
  "fee_tiers": (
115
114
  f"{len(fee_schedule.global_)} global / {len(fee_schedule.per_asset)} per-asset"
116
115
  if fee_schedule
@@ -121,6 +120,14 @@ def _list(
121
120
  render(records, output_format, no_pager=no_pager)
122
121
 
123
122
 
123
+ def _symbol_map_group(market: MarketResponse) -> int:
124
+ """Markets with a symbol, then index ids missing from the symbol map, then address ids."""
125
+ if market.asset.symbol is not None:
126
+ return 0
127
+
128
+ return 1 if market.asset_id.indexed else 2
129
+
130
+
124
131
  @markets.command("symbol-map")
125
132
  @orderbook_url_option()
126
133
  @ignore_ssl_option()
@@ -129,24 +136,35 @@ def _list(
129
136
  @no_pager_option()
130
137
  @pass_cli_context
131
138
  def _symbol_map(cli_ctx: CLIContext, output_format: str, no_pager: bool):
132
- """Show the canonical asset table served by the OMS."""
139
+ """Show each market's symbol-map identity, markets with a symbol first."""
133
140
  client = cli_ctx.orderbook_client()
134
- symbol_map = asyncio.run(client.get_markets(include_symbol_map=True)).symbol_map or {}
141
+ markets = asyncio.run(_collect_markets(client, None, None))
142
+ # `sorted` is stable, so each group keeps the `/markets` order.
143
+ markets = sorted(markets, key=_symbol_map_group)
135
144
  if output_format == "raw":
136
- raw = {str(index): asset.model_dump() for index, asset in symbol_map.items()}
145
+ raw = {str(market.asset_id): market.asset.model_dump() for market in markets}
137
146
  click.echo(json.dumps(raw, indent=2))
138
147
  return
139
148
 
140
- records = [
141
- {
142
- "index": index,
143
- "symbol": asset.symbol,
144
- "name": asset.name,
145
- "asset_class": asset.asset_class,
146
- "representations": ", ".join(asset.representations),
147
- }
148
- for index, asset in sorted(symbol_map.items())
149
- ]
149
+ records = []
150
+ for market in markets:
151
+ asset = market.asset
152
+ records.append(
153
+ {
154
+ "asset_id": str(market.asset_id),
155
+ "symbol": asset.symbol,
156
+ "name": asset.name,
157
+ "asset_class": asset.asset_class,
158
+ "representations": (
159
+ ", ".join(asset.representations) if asset.representations is not None else None
160
+ ),
161
+ "chain_assets": (
162
+ ", ".join(f"{chain.chain} {chain.address}" for chain in asset.chain_assets)
163
+ if asset.chain_assets is not None
164
+ else None
165
+ ),
166
+ }
167
+ )
150
168
  render(records, output_format, no_pager=no_pager)
151
169
 
152
170
 
@@ -27,7 +27,7 @@ def orders():
27
27
  @orderbook_url_option()
28
28
  @ignore_ssl_option()
29
29
  @tplus_account_option()
30
- @click.option("--asset", "asset_id", required=True, help="Asset identifier.")
30
+ @click.option("--asset", "asset_id", required=True, help="Asset index.")
31
31
  @click.option(
32
32
  "--side",
33
33
  type=click.Choice(["buy", "sell"], case_sensitive=False),
@@ -140,17 +140,12 @@ def _replace(
140
140
  def _transfer(
141
141
  cli_ctx: CLIContext, source_index: int, target_index: int, asset_id: str, amount: int
142
142
  ):
143
- """Transfer between sub-accounts."""
143
+ """Transfer between funding and trading accounts."""
144
144
  from tplus.model.asset_identifier import AssetIdentifier
145
145
 
146
146
  client = cli_ctx.orderbook_client()
147
147
  response = asyncio.run(
148
- client.request_transfer_to_subaccount(
149
- source_index=source_index,
150
- target_index=target_index,
151
- transfer_asset=AssetIdentifier(asset_id),
152
- transfer_amount=amount,
153
- )
148
+ client.request_transfer(source_index, target_index, AssetIdentifier(asset_id), amount)
154
149
  )
155
150
  click.echo(json.dumps(response, indent=2, default=str))
156
151
 
@@ -160,10 +155,19 @@ def _transfer(
160
155
  @ignore_ssl_option()
161
156
  @tplus_account_option()
162
157
  @click.option("--account", "account_index", type=int, required=True, help="Sub-account index.")
163
- @click.option("--asset", "asset_id", required=True, help="Transfer asset identifier.")
158
+ @click.option("--asset", "asset_id", required=True, help="Asset identifier of the position.")
164
159
  @pass_cli_context
165
160
  def _close(cli_ctx: CLIContext, account_index: int, asset_id: str):
166
- """Close a position on a sub-account."""
161
+ """Close a position on a sub-account.
162
+
163
+ Spot of the asset is first squashed into the position's base liabilities
164
+ (any asset, not only USD), but only while the quote leg is exactly zero: a
165
+ short with a quote leg is closed by trading. Once the base leg is flat, spot
166
+ USD repays a quote loss and a quote profit is moved to spot USD. A long
167
+ moves only a quote profit to spot USD and keeps its base. Any other open
168
+ position is rejected with ``No settled PnL while the long is open`` or
169
+ ``No settled PnL while the short is open``.
170
+ """
167
171
  client = cli_ctx.orderbook_client()
168
172
  response = asyncio.run(client.request_close_position(account_index, asset_id))
169
173
  click.echo(json.dumps(response, indent=2, default=str))
@@ -13,8 +13,10 @@ from tplus._cli._context import (
13
13
  tplus_account_option,
14
14
  )
15
15
  from tplus.cli_tools import (
16
+ describe_schedule_event,
16
17
  ignore_ssl_option,
17
18
  no_pager_option,
19
+ op_id_option,
18
20
  output_format_option,
19
21
  registry_address_option,
20
22
  render,
@@ -135,12 +137,14 @@ if _EVM_AVAILABLE:
135
137
  params_json: str,
136
138
  registry_address: str | None,
137
139
  ):
138
- """Set pending risk parameters for asset INDEX."""
140
+ """Schedule risk parameters for asset INDEX, signed by the account as the risk council."""
139
141
  owner = _build_owner(cli_ctx, account, registry_address=registry_address)
140
- receipt = owner.set_pending_risk_parameters(index, json.loads(params_json))
141
- click.echo(f"tx: {receipt.txn_hash}")
142
+ schedule_event = owner.schedule_operation(
143
+ "RISK_PARAMETERS", [index, json.loads(params_json)]
144
+ )
145
+ click.echo(describe_schedule_event(schedule_event))
142
146
 
143
- @params.command("apply", cls=ConnectedProviderCommand)
147
+ @params.command("execute", cls=ConnectedProviderCommand)
144
148
  @tplus_network_option()
145
149
  @clearing_url_option()
146
150
  @ignore_ssl_option()
@@ -148,11 +152,22 @@ if _EVM_AVAILABLE:
148
152
  @tplus_account_option()
149
153
  @account_option()
150
154
  @click.argument("index", type=int)
155
+ @click.option("--params", "params_json", required=True, help="The scheduled risk parameters.")
156
+ @op_id_option()
151
157
  @pass_cli_context
152
- def _apply(cli_ctx: CLIContext, account, index: int, registry_address: str | None):
153
- """Apply pending risk parameters for asset INDEX."""
158
+ def _execute(
159
+ cli_ctx: CLIContext,
160
+ account,
161
+ index: int,
162
+ params_json: str,
163
+ op_id: bytes,
164
+ registry_address: str | None,
165
+ ):
166
+ """Execute the risk parameters scheduled for asset INDEX."""
154
167
  owner = _build_owner(cli_ctx, account, registry_address=registry_address)
155
- receipt = owner.apply_pending_risk_parameters(index)
168
+ receipt = owner.execute_operation(
169
+ "RISK_PARAMETERS", [index, json.loads(params_json)], op_id
170
+ )
156
171
  click.echo(f"tx: {receipt.txn_hash}")
157
172
 
158
173
  else: