Code Monkey home page Code Monkey logo

pyth-client-py's People

Contributors

ali-bahjati avatar anihamde avatar cctdaniel avatar erancx avatar hkey0 avatar jayantk avatar murmer-blip avatar sejeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyth-client-py's Issues

Problem with using Solana Mainnet, might be about mapping key

Problem Description

I'm trying to read all price from solana by each time I call the function. When I set solana_network with devnet, it was working perfect. However, when I try to use mainet, testnet, or pythnet, it can't work anymore.

Calling method

solana_network="mainnet" 
use_program = True

async def SolanaPythClientPriceFunction():
    async with PythClient(
        first_mapping_account_key=get_key(solana_network, "mapping"),
        program_key=get_key(solana_network, "program") if use_program else None,
    ) as c:
        await c.refresh_all_prices()

Debug Console Output

.....venv\Lib\site-packages\pythclient\pythclient.py", line 185, in _refresh_mapping_accounts
    raise exceptions.MissingAccountException(f"need account {key} but missing in getProgramAccount response")
pythclient.exceptions.MissingAccountException: need account AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J but missing in getProgramAccount response

I checked the variables with debugger.

async def _refresh_mapping_accounts(self, *, account_json: Optional[Dict[str, Any]] = None, slot: Optional[int] = None) -> List[PythMappingAccount]:
key = self._first_mapping_account_key
existing_mappings = dict((mapping.key, mapping) for mapping in self._mapping_accounts) if self._mapping_accounts else {}
mapping_accounts: List[PythMappingAccount] = []
while key:
m = existing_mappings.get(key) or PythMappingAccount(key, self.solana)
if account_json is not None:
m_data = account_json.get(str(key))
if m_data is None:
raise exceptions.MissingAccountException(f"need account {key} but missing in getProgramAccount response")
assert slot
m.update_with_rpc_response(slot, m_data)
else:
await m.update()
mapping_accounts.append(m)
key = m.next_account_key
self._mapping_accounts = mapping_accounts
return self._mapping_accounts

Until L180, everything works fine. Both key was correctly assigned values. But then, at L183,
m_data = account_json.get(AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J )
it reads empty data.

Is this an error with mapping key? ( I checked with Pyth Network Website, the key is as same as here) Or with the method that I calling it?

Remove hardcoded mapping and program account keys

Problem

Hardcoding mapping or program keys is not ideal. This is also hardcoded only for devnet.

V1_FIRST_MAPPING_ACCOUNT_KEY = "ArppEFcsybCLE8CRtQJLQ9tLv2peGmQoKWFuiUWm4KBP"
V2_FIRST_MAPPING_ACCOUNT_KEY = "BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2"
V2_PROGRAM_KEY = "gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s"

Backgrournd

There are new dns records for all of these which should be looked up at runtime via a helper:

The following dns TXT records exist as authoritative references to these keys:

devnet-mapping-v2.pyth.network
devnet-program-v2.pyth.network
mainnet-mapping-v2.pyth.network
mainnet-program-v2.pyth.network
testnet-mapping-v2.pyth.network
testnet-program-v2.pyth.network

A shell example of looking them up:

$ for network in dev main test; do
    for type in mapping program; do
        key=$(host -t TXT ${network}net-${type}-v2.pyth.network | awk -F'[="]' '/(mapping|program)=/{print $3}')
        echo "$network $type key=$key"
    done
done

dev mapping key=BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2
dev program key=gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s
main mapping key=AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J
main program key=FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH
test mapping key=AFmdnt9ng1uVxqCmqwQJDAYC5cKTkw8gJKSM5PnzuF6z
test program key=8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz

Solution

Implement some helpers to look up these keys from dns. Have that be the way to solve this in the python client.

More docmentation

Hi, just wondering how I would:

  • get a list of oracles available on pyth?
  • query price date at historical points/ranges?

thank you

Create Github Action pytests

On a pull_request a github action will execute and do the following:

  1. Run on ubuntu-latest (and we can also run it on Windows, MacOS for extended coverage)
  2. Install multiple Python versions (3.7, 3.8, 3.9 etc)
  3. Install python dependencies
  4. Run flake8 on the code to find Python syntax errors or undefined names
  5. Run Pytest
  6. Upload artifact from workflow to shared data (optional)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.