Skip to main content

Rysk Client

alt text

The rysk python client offers a programatic means by which to interact with the Rysk Finance Protocol.

The DHV is a hybrid AMM and RFQ options protocol, generating uncorrelated returns for its liquidity providers whilst enabling anyone to trade (buy and sell) options with a wide range of strike prices and expiry dates. The DHV uses a dynamic approach in hedging risk to generate market-neutral uncorrelated returns for liquidity providers.

The Rysk client is a python client that allows users to interact with the Rysk protocol. The client is built on top of the web3.py and the Open-Aea python libraries. The client allows users to interact with the Rysk protocol in a programatic manner.

Installation

The application is available on pypi and can be installed as so

pip install rysk-client

Cli Tool

The application is also bundled as cli tool to allow users to interact with the protocol from the cli.

alt text

Setting Up The Env

There are a few varaibles which can be configured to modify the behaviour of the client. These are:

  • ETH_ADDRESS: The address of the Ethereum account to use for the client. This account must have a balance of ARB to pay for gas fees.
  • ETH_PRIVATE_KEY: The private key of the Ethereum account to use for the client. This account must have a balance of ARB to pay for gas fees.
  • CHAIN: The chain to connect to. This can be either 'arbitrum' or 'arbitrum-goerli'.

Creating a Client

Clients can be created from the rysk client module using python code.

from rysk_client.client import RyskClient
from rysk_client.src.constants import ARBITRUM, ARBITRUM_GOERLI
from tests.conftest import DEFAULT_ADDRESS

auth = {
    "address": DEFAULT_ADDRESS,
}

# we can also set the chain to arbitrum  NOTE by default the chain is arbitrum goerli

chain = ARBITRUM
chain = ARBITRUM_GOERLI

client = RyskClient(**auth, chain=chain)
client
Rysk client initialized and connected to the blockchain at RPC connection https://arbitrum.public-rpc.com





RyskClient(_markets=[], _tickers=[], _otokens={}, web3_client=<rysk_client.web3_client.Web3Client object at 0x7ff0995ded10>)

Markets

We can fetch data about the markets as so;

markets = client.fetch_markets()
markets[0]
{'id': 'ETH-29SEP23-1800-C',
 'strike': 1800.0,
 'expiration': 1695974400,
 'optionType': 'call',
 'active': True,
 'delta': 0.6189098962288028,
 'bid': 121.382234,
 'ask': 130.231078,
 'dhv': 0.1}

Fetching Tickers

Tickers can be fetched from the client as so;

tickers = client.fetch_tickers()
tickers[0]
{'id': 'ETH-29SEP23-1800-C',
 'strike': 1800.0,
 'expiration': 1695974400,
 'optionType': 'call',
 'active': True,
 'delta': 0.6189098962288028,
 'bid': 121.382234,
 'ask': 130.231078,
 'dhv': 0.1}

Fetching Positions

Positions are fetched from the client such that a user can retrieve their positions.

Positions are indicated by a vault id.

The vaultid iterates when a new position is created.

Vaultid can be retrieved from;

positions = client.fetch_positions()
positions[0]
{'id': '0x9b8a204636a7aa9c33053d9c3a828720d32212e8-0x5c82b8d5a5306c48e9ac5fc07559a6961bd1ad1e-l-0',
 'symbol': 'ETH-29SEP23-1800-C',
 'timestamp': 1695974400000,
 'datetime': datetime.datetime(2023, 9, 29, 9, 0),
 'initialMarginPercentage': None,
 'realizedPnl': -0.9503399999999971,
 'unrealizedPnl': 0.0,
 'contractSize': 0.0,
 'side': 'long',
 'size': 0.0,
 'info': {'id': '0x9b8a204636a7aa9c33053d9c3a828720d32212e8-0x5c82b8d5a5306c48e9ac5fc07559a6961bd1ad1e-l-0',
  'netAmount': '0',
  'buyAmount': '200000000000000000',
  'sellAmount': '200000000000000000',
  'active': False,
  'realizedPnl': '-1150340',
  'oToken': {'id': '0x5c82b8d5a5306c48e9ac5fc07559a6961bd1ad1e',
   'symbol': 'oWETHUSDC/USDC-29SEP23-1800C',
   'expiryTimestamp': '1695974400',
   'strikePrice': '180000000000',
   'isPut': False,
   'underlyingAsset': {'id': '0x3b3a1de07439eeb04492fa64a889ee25a130cdd3'},
   'createdAt': '1689849479'},
  'redeemActions': [],
  'optionsBoughtTransactions': [{'amount': '100000000000000000',
    'premium': '12841201'},
   {'amount': '100000000000000000', 'premium': '13438848'}],
  'optionsSoldTransactions': [{'amount': '200000000000000000',
    'premium': '25329709'}],
  'expiration_datetime': datetime.datetime(2023, 9, 29, 9, 0),
  'strike': 1.8e+21,
  'isPut': False},
 'entryPrice': 0}

Dev & Contributing

Dependencies are managed with poetry.

For dev build.

poetry install 
poetry shell 

Tests

!poetry run pytest tests
============================= test session starts ==============================
platform linux -- Python 3.10.4, pytest-7.2.1, pluggy-1.2.0
rootdir: /home/tom/Desktop/Fun/rysk/rysk_explorations, configfile: pytest.ini
plugins: cov-3.0.0, web3-5.31.0, anyio-3.7.1, pylama-8.4.1, rerunfailures-11.1.2
collected 78 items                                                             

tests/test_client.py::test_fetch_markets PASSED                          [  1%]
tests/test_client.py::test_fetch_tickers PASSED                          [  2%]
tests/test_client.py::test_fetch_positions PASSED                        [  3%]
tests/test_client.py::test_create_buy_order[ETH-28JUL23-1900-C] PASSED   [  5%]
tests/test_client.py::test_create_buy_order[ETH-28JUL23-1900-P] PASSED   [  6%]
tests/test_client.py::test_create_sell_order PASSED                      [  7%]
tests/test_collateral.py::test_get_collateral[usdc] PASSED               [  8%]
tests/test_collateral.py::test_get_collateral[weth] PASSED               [ 10%]
tests/test_collateral.py::test_supported_collateral[usdc] PASSED         [ 11%]
tests/test_collateral.py::test_supported_collateral[weth] PASSED         [ 12%]
tests/test_collateral.py::test_unsupported_collateral[btc] PASSED        [ 14%]
tests/test_collateral.py::test_unsupported_collateral[doge] PASSED       [ 15%]
tests/test_contract_calls.py::test_local_fork PASSED                     [ 16%]
tests/test_contract_calls.py::test_get_block_number PASSED               [ 17%]
tests/test_contract_calls.py::test_settle_vault[6] SKIPPED (Pending ...) [ 19%]
tests/test_contract_calls.py::test_settle_vault[9] SKIPPED (Pending ...) [ 20%]
tests/test_contract_calls.py::test_settle_vault[15] SKIPPED (Pending...) [ 21%]
tests/test_contract_calls.py::test_fails_to_settle_vault PASSED          [ 23%]
tests/test_contract_calls.py::test_redeems_o_token SKIPPED (Pending ...) [ 24%]
tests/test_contract_calls.py::test_retieve_and_redeem[ETH-02JUN23-1900-P-30] SKIPPED [ 25%]
tests/test_contract_calls.py::test_retieve_and_redeem[ETH-09JUN23-1900-P-360] SKIPPED [ 26%]
tests/test_contract_calls.py::test_redeem_market_from_str[ETH-02JUN23-1900-P] SKIPPED [ 28%]
tests/test_contract_calls.py::test_client_can_buy[ETH-28JUL23-1900-C-5] PASSED [ 29%]
tests/test_contract_calls.py::test_client_can_buy[ETH-28JUL23-2000-C-5] PASSED [ 30%]
tests/test_contract_calls.py::test_client_can_buy[ETH-28JUL23-1800-P-5] PASSED [ 32%]
tests/test_contract_calls.py::test_client_can_buy[ETH-28JUL23-1900-P-5] PASSED [ 33%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-2000-C-1] PASSED [ 34%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-1900-C-2] PASSED [ 35%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-1800-P-3] PASSED [ 37%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-2000-C-4] PASSED [ 38%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-1900-C-5] PASSED [ 39%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-1800-P-6] PASSED [ 41%]
tests/test_contract_calls.py::test_client_can_buy_differing_amounts[ETH-28JUL23-2000-C-7] PASSED [ 42%]

Formating and linting

!make fmt lint
poetry run black tests rysk_client && poetry run isort tests rysk_client 
reformatted tests/conftest.py
reformatted tests/test_rysk_option_market.py
reformatted rysk_client/packages/eightballer/contracts/user_position_lens/contract.py
reformatted rysk_client/src/utils.py
reformatted rysk_client/src/operation_factory.py
reformatted rysk_client/packages/eightballer/contracts/option_exchange/contract.py
reformatted rysk_client/packages/eightballer/contracts/opyn_controller/contract.py
reformatted rysk_client/packages/eightballer/contracts/opyn_option_registry/contract.py
reformatted rysk_client/web3_client.py
reformatted rysk_client/client.py

All done! ✨ 🍰 ✨
10 files reformatted, 39 files left unchanged.
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/tests/test_rysk_option_market.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/tests/conftest.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/client.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/web3_client.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/packages/eightballer/contracts/user_position_lens/contract.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/packages/eightballer/contracts/opyn_option_registry/contract.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/packages/eightballer/contracts/option_exchange/contract.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/packages/eightballer/contracts/opyn_controller/contract.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/src/operation_factory.py
Fixing /home/tom/Desktop/Fun/rysk/rysk_explorations/rysk_client/src/utils.py
Skipped 9 files
poetry run adev -v -n 0 lint -p tests
[19:16:04] DEBUG    Consider installing rusty-rlp to improve pyrlp   ]8;id=871982;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/rlp/codec.py\codec.py]8;;\:]8;id=423867;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/rlp/codec.py#26\26]8;;\
                    performance with a rust based backend                       
           INFO     Starting Auto Dev v0.2.6 ...                      ]8;id=777441;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=390191;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#72\72]8;;\
           INFO     Verbose mode enabled                              ]8;id=656669;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=690015;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#75\75]8;;\
           INFO     Using 32 processes for processing                 ]8;id=300635;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=723439;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#77\77]8;;\
           INFO     Setting log level to INFO                         ]8;id=59445;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=408112;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#79\79]8;;\
           INFO     Linting Open Autonomy Packages                    ]8;id=656444;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=861569;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#37\37]8;;\
           INFO     Linting 12 files...                               ]8;id=422140;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=648455;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#39\39]8;;\
[19:16:09] INFO     Linting completed with 12 passed and 0 failed     ]8;id=16054;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=321483;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#46\46]8;;\
poetry run adev -v -n 0 lint -p rysk_client
[19:16:10] DEBUG    Consider installing rusty-rlp to improve pyrlp   ]8;id=924141;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/rlp/codec.py\codec.py]8;;\:]8;id=620693;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/rlp/codec.py#26\26]8;;\
                    performance with a rust based backend                       
[19:16:11] INFO     Starting Auto Dev v0.2.6 ...                      ]8;id=109749;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=900199;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#72\72]8;;\
           INFO     Verbose mode enabled                              ]8;id=607608;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=519072;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#75\75]8;;\
           INFO     Using 32 processes for processing                 ]8;id=302243;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=356880;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#77\77]8;;\
           INFO     Setting log level to INFO                         ]8;id=822518;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py\base.py]8;;\:]8;id=634619;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/base.py#79\79]8;;\
           INFO     Linting Open Autonomy Packages                    ]8;id=550306;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=189039;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#37\37]8;;\
           INFO     Linting 37 files...                               ]8;id=733237;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=406955;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#39\39]8;;\
[19:16:19] INFO     Linting completed with 37 passed and 0 failed     ]8;id=571940;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py\lint.py]8;;\:]8;id=671018;file:///home/tom/.cache/pypoetry/virtualenvs/rysk-client-Q6-gVAE8-py3.10/lib/python3.10/site-packages/auto_dev/commands/lint.py#46\46]8;;\

Releasing

Git ops is used to enable automated releases via pypi.

export NEW_VERSION=0.2.11
git checkout -b v$NEW_VERSION &&
    bumpversion  rysk_client/ --new-version $NEW_VERSION && 
git push --set-upstream origin (git rev-parse --abbrev-ref HEAD) && git push --tag

Metadata

Release files for rysk-client 0.2.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rysk-client 0.2.17
File Size Uploaded Provenance Actions
rysk_client-0.2.17.tar.gz 54.5 kB Without provenance Details for rysk_client-0.2.17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rysk-client 0.2.17
File Interpreter ABI Platform Actions
rysk_client-0.2.17-py3-none-any.whl Python 3 none any Details for rysk_client-0.2.17-py3-none-any.whl

Total release size: 129.9 kB

Release files / rysk_client-0.2.17.tar.gz

Download URL rysk_client-0.2.17.tar.gz
Size 54.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2782951d9971fd7373a1088a7ad81e378eae1ab313059dbec9aa93b29f4a74e6
BLAKE2b-256 checksum
How to use checksums
eecb6df89c7b1618f61c3002bb017d9ec1ace659d65503b475e64491016bc11b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / rysk_client-0.2.17-py3-none-any.whl

Download URL rysk_client-0.2.17-py3-none-any.whl
Size 75.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ad51e393ca3cf8343890d7bef20a5db8820eef0038db290705ab77031e70dc9
BLAKE2b-256 checksum
How to use checksums
ab3acb792c334a0ac508d8d891b5c525db5201103a34a9bac53a0bf38d215c6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Security for rysk-client 0.2.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page