## KomoDeFi Framework wrapper for Python
**pykomodefi** is a simple wrapper around [Komodo Platform's](https://komodoplatform.com/en/) [DeFi Framework](https://github.com/KomodoPlatform/komodo-defi-framework).
### Installation
`pip install pykomodefi`
### Usage
**Configuration:**
The configuration file can be passed as a parameter to the `KomoDeFi_API` class constructor:
```
>>> import pykomodefi
>>> dexapi = pykomodefi.KomoDeFi_API(config="/path/to/MM2.json")
```
If not set, the default configuration file path is `MM2.json` in the current folder.
It can be set to a different file later:
```
>>> import pykomodefi
>>> dexapi = pykomodefi.KomoDeFi_API()
>>> dexapi.set_config = "/path/to/MM2.json"
```
**Simple RPC call:**
```
>>> r = dexapi.rpc("get_enabled_coins")
>>> r
<Response [200]>
>>> r.status_code
200
>>> r.json()
{
'result': [
{
'ticker': 'KMD',
'address': 'RMC1cWXngQf2117apEKoLh3x27NoG88yzd'
},
{
'ticker': 'LTC',
'address': 'LQyzwFtf8HU7VYQMhop5bv857uMao4jnKX'
}
]
}
```
**RPC call with parameters:**
```
>>> params = {"coin": "KMD"}
>>> r = dexapi.rpc("my_balance", params)
>>> r.json()
{
'coin': 'KMD',
'balance': '20',
'unspendable_balance': '0',
'address': 'RMC1cWXngQf2117apEKoLh3x27NoG88yzd'
}
```
**v2 RPC call:**
```
>>> r = dexapi.rpc("get_public_key", v2=True)
>>> r.json()
{
'mmrpc': '2.0',
'result': {
'public_key': '0371792f7a6846a0da28f3422501927ae103355c02750bc4c4d8430375329a09ac'
},
'id': None
}
```
The following methods are available as properties of the `KomoDeFi_API` class. These methods do not require any input parameters:
```
>>> dexapi.version
'1.0.7-beta_afe2e08'
>>> dexapi.pubkey
'0366d28a7926fb20287132692c4cef7bc7e00e76da064948676f8549c0ed7114d3'
>>> dexapi.pubkey_hash
'05aab5342166f8594baf17a7d9bef5d567443327'
>>> dexapi.peer_id
'12D3KooWS9MeuFZhJCfQTntwbTVnXMAJpz9Tvd1XYFuURrGqnJVR'
>>> dexapi.peers_info
{
"12D3KooWM8BrDBXc1TVw2vswoqYcQVn7fFvpAvcCfaV2Uqg2L9jU":["/ip4/89.248.168.39/tcp/38890"],
"12D3KooWJ3dEWK7ym1uwc5SmwbmfFSRmELrA9aPJYxFRrQCCNdwF":["/ip4/188.124.46.112/tcp/38890/p2p/12D3KooWJ3dEWK7ym1uwc5SmwbmfFSRmELrA9aPJYxFRrQCCNdwF"],
"12D3KooWL6yrrNACb7t7RPyTEPxKmq8jtrcbkcNd6H5G2hK7bXaL":["/ip4/168.119.236.233/tcp/38890/p2p/12D3KooWL6yrrNACb7t7RPyTEPxKmq8jtrcbkcNd6H5G2hK7bXaL"],
"12D3KooWPR2RoPi19vQtLugjCdvVmCcGLP2iXAzbDfP3tp81ZL4d":["/ip4/168.119.237.13/tcp/38890/p2p/12D3KooWPR2RoPi19vQtLugjCdvVmCcGLP2iXAzbDfP3tp81ZL4d"],
"12D3KooWKxavLCJVrQ5Gk1kd9m6cohctGQBmiKPS9XQFoXEoyGmS":["/ip4/168.119.236.249/tcp/38890/p2p/12D3KooWKxavLCJVrQ5Gk1kd9m6cohctGQBmiKPS9XQFoXEoyGmS"],
"12D3KooWDbBdifGp3viDR4dCECEFKepjhwhd2YwAqgNVdXpEeewu":["/ip4/80.82.76.214/tcp/38890"],
"12D3KooWJDoV9vJdy6PnzwVETZ3fWGMhV41VhSbocR1h2geFqq9Y":["/ip4/89.248.173.231/tcp/38890"]
}
>>> dexapi.orders
{
"maker_orders": {
....
},
"taker_orders": {
....
}
}
>>> dexapi.active_swaps
{
"uuids": [
"015c13bc-da79-43e1-a6d4-4ac8b3099b34",
"7592a07a-2805-4050-8ab8-984480e812f0",
"82cbad96-ea9f-40fb-9225-07496323e35d",
"177f7fa5-c9f3-4673-a2fa-28451a123e61"
]
}
>>> dexapi.enabled_coins
[
{
"address": "1WxswvLF2HdaDr4k77e92VjaXuPQA8Uji",
"ticker": "BTC"
},
{
"address": "R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW",
"ticker": "KMD"
},
{
"address": "R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW",
"ticker": "VRSC"
},
{
"address": "0xbAB36286672fbdc7B250804bf6D14Be0dF69fa29",
"ticker": "ETH"
}
]
```
For documentation about available methods and parameters, refer to: <https://developers.komodoplatform.com/basic-docs/atomicdex/introduction-to-atomicdex.html>
### Building locally
- Run `poetry build`
- Run `pipx install --spec $(pwd)/dist/pykomodefi-0.2.4.tar.gz pykomodefi --include-deps --force` (change version number accordingly)
### Running tests
- Set MM2.json path for tests in `/test/.env`
- Run `poetry run pytest -vv`
Raw data
{
"_id": null,
"home_page": "https://github.com/smk762/pykomodefi",
"name": "pykomodefi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0.0",
"maintainer_email": "",
"keywords": "dex,crypto,komodo,defi,api,trading,atomic swaps",
"author": "smk",
"author_email": "smk@komodoplatform.com",
"download_url": "https://files.pythonhosted.org/packages/1d/eb/ecabcfb0a231908d86bf28d7b4f0897999db532e0337b68173e9d5f0dbdd/pykomodefi-0.2.4.tar.gz",
"platform": null,
"description": "\n## KomoDeFi Framework wrapper for Python\n\n**pykomodefi** is a simple wrapper around [Komodo Platform's](https://komodoplatform.com/en/) [DeFi Framework](https://github.com/KomodoPlatform/komodo-defi-framework).\n\n\n### Installation\n\n`pip install pykomodefi`\n\n\n### Usage\n\n**Configuration:**\n\nThe configuration file can be passed as a parameter to the `KomoDeFi_API` class constructor:\n\n```\n >>> import pykomodefi\n >>> dexapi = pykomodefi.KomoDeFi_API(config=\"/path/to/MM2.json\")\n```\nIf not set, the default configuration file path is `MM2.json` in the current folder.\nIt can be set to a different file later:\n\n```\n >>> import pykomodefi\n >>> dexapi = pykomodefi.KomoDeFi_API()\n >>> dexapi.set_config = \"/path/to/MM2.json\"\n```\n\n\n**Simple RPC call:**\n```\n >>> r = dexapi.rpc(\"get_enabled_coins\")\n >>> r\n <Response [200]>\n\n >>> r.status_code\n 200\n\n >>> r.json()\n {\n 'result': [\n {\n 'ticker': 'KMD',\n 'address': 'RMC1cWXngQf2117apEKoLh3x27NoG88yzd'\n },\n {\n 'ticker': 'LTC',\n 'address': 'LQyzwFtf8HU7VYQMhop5bv857uMao4jnKX'\n }\n ]\n }\n```\n \n**RPC call with parameters:**\n```\n >>> params = {\"coin\": \"KMD\"}\n >>> r = dexapi.rpc(\"my_balance\", params)\n >>> r.json()\n {\n 'coin': 'KMD',\n 'balance': '20',\n 'unspendable_balance': '0',\n 'address': 'RMC1cWXngQf2117apEKoLh3x27NoG88yzd'\n }\n```\n\n**v2 RPC call:**\n```\n >>> r = dexapi.rpc(\"get_public_key\", v2=True)\n >>> r.json()\n {\n 'mmrpc': '2.0',\n 'result': {\n 'public_key': '0371792f7a6846a0da28f3422501927ae103355c02750bc4c4d8430375329a09ac'\n },\n 'id': None\n }\n```\n\n\nThe following methods are available as properties of the `KomoDeFi_API` class. These methods do not require any input parameters:\n```\n >>> dexapi.version\n '1.0.7-beta_afe2e08'\n\n >>> dexapi.pubkey\n '0366d28a7926fb20287132692c4cef7bc7e00e76da064948676f8549c0ed7114d3'\n\n >>> dexapi.pubkey_hash\n '05aab5342166f8594baf17a7d9bef5d567443327'\n\n >>> dexapi.peer_id\n '12D3KooWS9MeuFZhJCfQTntwbTVnXMAJpz9Tvd1XYFuURrGqnJVR'\n\n >>> dexapi.peers_info\n {\n \"12D3KooWM8BrDBXc1TVw2vswoqYcQVn7fFvpAvcCfaV2Uqg2L9jU\":[\"/ip4/89.248.168.39/tcp/38890\"],\n \"12D3KooWJ3dEWK7ym1uwc5SmwbmfFSRmELrA9aPJYxFRrQCCNdwF\":[\"/ip4/188.124.46.112/tcp/38890/p2p/12D3KooWJ3dEWK7ym1uwc5SmwbmfFSRmELrA9aPJYxFRrQCCNdwF\"],\n \"12D3KooWL6yrrNACb7t7RPyTEPxKmq8jtrcbkcNd6H5G2hK7bXaL\":[\"/ip4/168.119.236.233/tcp/38890/p2p/12D3KooWL6yrrNACb7t7RPyTEPxKmq8jtrcbkcNd6H5G2hK7bXaL\"],\n \"12D3KooWPR2RoPi19vQtLugjCdvVmCcGLP2iXAzbDfP3tp81ZL4d\":[\"/ip4/168.119.237.13/tcp/38890/p2p/12D3KooWPR2RoPi19vQtLugjCdvVmCcGLP2iXAzbDfP3tp81ZL4d\"],\n \"12D3KooWKxavLCJVrQ5Gk1kd9m6cohctGQBmiKPS9XQFoXEoyGmS\":[\"/ip4/168.119.236.249/tcp/38890/p2p/12D3KooWKxavLCJVrQ5Gk1kd9m6cohctGQBmiKPS9XQFoXEoyGmS\"],\n \"12D3KooWDbBdifGp3viDR4dCECEFKepjhwhd2YwAqgNVdXpEeewu\":[\"/ip4/80.82.76.214/tcp/38890\"],\n \"12D3KooWJDoV9vJdy6PnzwVETZ3fWGMhV41VhSbocR1h2geFqq9Y\":[\"/ip4/89.248.173.231/tcp/38890\"]\n }\n\n >>> dexapi.orders\n {\n \"maker_orders\": {\n ....\n },\n \"taker_orders\": {\n ....\n }\n }\n\n >>> dexapi.active_swaps\n {\n \"uuids\": [\n \"015c13bc-da79-43e1-a6d4-4ac8b3099b34\",\n \"7592a07a-2805-4050-8ab8-984480e812f0\",\n \"82cbad96-ea9f-40fb-9225-07496323e35d\",\n \"177f7fa5-c9f3-4673-a2fa-28451a123e61\"\n ]\n }\n\n >>> dexapi.enabled_coins\n [\n {\n \"address\": \"1WxswvLF2HdaDr4k77e92VjaXuPQA8Uji\",\n \"ticker\": \"BTC\"\n },\n {\n \"address\": \"R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW\",\n \"ticker\": \"KMD\"\n },\n {\n \"address\": \"R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW\",\n \"ticker\": \"VRSC\"\n },\n {\n \"address\": \"0xbAB36286672fbdc7B250804bf6D14Be0dF69fa29\",\n \"ticker\": \"ETH\"\n }\n ]\n```\n\nFor documentation about available methods and parameters, refer to: <https://developers.komodoplatform.com/basic-docs/atomicdex/introduction-to-atomicdex.html>\n\n\n### Building locally\n\n- Run `poetry build`\n- Run `pipx install --spec $(pwd)/dist/pykomodefi-0.2.4.tar.gz pykomodefi --include-deps --force` (change version number accordingly)\n\n### Running tests\n\n- Set MM2.json path for tests in `/test/.env`\n- Run `poetry run pytest -vv`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A wrapper for the Komodo DeFi Framework API",
"version": "0.2.4",
"project_urls": {
"Documentation": "https://github.com/smk762/pykomodefi",
"Homepage": "https://github.com/smk762/pykomodefi",
"Repository": "https://github.com/smk762/pykomodefi"
},
"split_keywords": [
"dex",
"crypto",
"komodo",
"defi",
"api",
"trading",
"atomic swaps"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "62a2897117956a347778649431afcd6d673d192d6245a43569afc624c20aa33d",
"md5": "5070474a289f22ead264fd0673d5912b",
"sha256": "eecb4d83403b66ea7f2e10892422067d7d39a5a66729201abcd5d456b34019b1"
},
"downloads": -1,
"filename": "pykomodefi-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5070474a289f22ead264fd0673d5912b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0.0",
"size": 29712,
"upload_time": "2023-12-02T07:36:38",
"upload_time_iso_8601": "2023-12-02T07:36:38.465185Z",
"url": "https://files.pythonhosted.org/packages/62/a2/897117956a347778649431afcd6d673d192d6245a43569afc624c20aa33d/pykomodefi-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1debecabcfb0a231908d86bf28d7b4f0897999db532e0337b68173e9d5f0dbdd",
"md5": "e79b61387746f71eb23ce67ef6028b15",
"sha256": "7889395cc4495c2a5a45893d44955bf5dc354aa426841cab56b3f9e18ad17273"
},
"downloads": -1,
"filename": "pykomodefi-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "e79b61387746f71eb23ce67ef6028b15",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0.0",
"size": 16526,
"upload_time": "2023-12-02T07:36:40",
"upload_time_iso_8601": "2023-12-02T07:36:40.510955Z",
"url": "https://files.pythonhosted.org/packages/1d/eb/ecabcfb0a231908d86bf28d7b4f0897999db532e0337b68173e9d5f0dbdd/pykomodefi-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-02 07:36:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "smk762",
"github_project": "pykomodefi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pykomodefi"
}