Giter VIP home page Giter VIP logo

kwenta-python-sdk's Introduction

CodeQL Discord Twitter Follow GitPOAP Badge

Kwenta

A dApp enabling derivatives trading — powered by the Synthetix protocol.

The decentralized trading UI is available at kwenta.eth.limo.

ENS link: kwenta.eth.

The latest IPFS hash can be found under releases.

Contributing

Kwenta welcomes contributors. Regardless of the time you have available, everyone can provide meaningful contributions to the project by submitting bug reports, feature requests or even the smallest of fixes! To submit your contribution, please fork, fix, commit and create a pull-request describing your work in detail. For more details, please have a look at the Contribution guidelines.

Tech stack

  • Next.js
  • React
  • Redux
  • Kwenta SDK
  • Styled-Components

Ethereum stack

Development

Install dependencies

pnpm install

Set up environment variables

Copy the .env.local.example file in the packages/app directory to .env.local (which will be ignored by Git):

cd packages/app
cp .env.local.example .env.local

Then, open .env.local and add the missing environment variables:

Required:

  • NEXT_PUBLIC_PROVIDER_ID - Specifies the default provider, options are INFURA or BLAST_API
  • NEXT_PUBLIC_INFURA_PROJECT_ID - Infura project id (get it from infura.io) or
  • NEXT_PUBLIC_BLASTAPI_PROJECT_ID - Blast API project id (get it from blastapi.io)
  • NEXT_PUBLIC_SOCKET_API_KEY - Socket API key (get it from socket.tech
  • NEXT_PUBLIC_SATSUMA_API_KEY - API key for Satsuma subgraph queries
  • NEXT_PUBLIC_THEGRAPH_API_KEY - API key for The Graph's decentralized service
  • NEXT_PUBLIC_DEFAULT_PRICE_SERVICE - Specifies the default price server, options are KWENTA or PYTH
  • NEXT_PUBLIC_SERVICES_PROXY - Specify Kwenta proxy server

Run

cd packages/app
pnpm dev

Open http://localhost:3000 to view it in the browser.

Build

cd packages/app
pnpm build
pnpm start

Unit Testing

cd packages/app
pnpm test:jest

For unit tests we use a combination of Jest and React Testing Library

Page tests should be added to the testing folder at the root as it is not possible to co-locate tests and pages in nextjs. Other tests should be co-located in a __tests__ folder next to their related file.

Contact

Join the community on the Kwenta Discord server!

kwenta-python-sdk's People

Contributors

koredefashokun avatar odessa99 avatar omahs avatar platschi avatar sainytk avatar tburm avatar tossayecoin avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

kwenta-python-sdk's Issues

Broken alerts

The Alerts methods send_message has a missing self argument. This method is not used anywhere in the code nor any examples, I guess it was never tested/used. Common Python mistake, can be easily spotted by running a static analysis. This type of analysis is recommended in Python as it is an interpreted language, it has no compile time before execution. So I recommend using pylance or flake8 to do so.

Remove dependency on sm_account to query kwenta

problem

I'm in your stack, touching your bits and playing with your stack and wrappers (fantastic work!!!)
However, to play with data I need to bridge to OP + create a smart margin account.

proposal

Enable user to instantiate with Kwenta(wallet_address=None, ...)
Handling sm_account to be None.

kwenta.py
ln 207: sm_account = self.get_sm_accounts()[0] if self.wallet_address else None

DoD

  • user can interact with all queries and functionality that do not rely on an sm_account

Fail to use network_id 420

Thank you for your repo,
I want to connect to testnet network then get price history and open-close position, but I got this error, can anyone help me fix that?
Code:

from kwenta import Kwenta

kwenta = Kwenta(
    network_id=420,
    provider_rpc="https://opt-goerli.g.alchemy.com/v2/...",
    wallet_address="0x...",
    private_key="0x..."
)

Error:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    kwenta = Kwenta(
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/site-packages/kwenta/kwenta.py", line 72, in __init__
    ) = self._load_markets()
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/site-packages/kwenta/kwenta.py", line 183, in _load_markets
    results = list(executor.map(self._load_market, allmarketsdata))
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/tuongnh/miniconda3/envs/trade/lib/python3.8/site-packages/kwenta/kwenta.py", line 116, in _load_market
    addresses["PerpsV2MarketSettings"][self.network_id]
KeyError: 420

Replicate isolated margin SDK functions

Isolated margin read functions

  • getMarkets
  • getFuturesPositions
  • getAverageFundingRates
  • getDailyVolumes
  • getIsolatedMarginTransfers
  • getDelayedOrder
  • getDelayedOrders
  • getIsFlagged
  • getIsolatedTradePreview
  • getPositionHistory
  • getTradesForMarket
  • getAllTrades
  • getFuturesTrades
  • getOrderFee

Isolated margin write functions

  • depositIsolatedMargin
  • withdrawIsolatedMargin
  • closeIsolatedPosition
  • modifyIsolatedMarginPosition
  • cancelDelayedOrder
  • executeDelayedOffchainOrder

Replicate smart margin SDK functions

Smart margin read function

  • getCrossMarginSettings
  • getCrossMarginTransfers
  • getCrossMarginAccounts
  • getCrossMarginBalanceInfo
  • getCrossMarginOpenOrders
  • getCrossMarginTradePreview
  • getCrossMarginKeeperBalance

Smart margin write functions (update with smart margin)

  • approveCrossMarginDeposit
  • depositCrossMargin
  • withdrawCrossMargin
  • submitCrossMarginOrder
  • closeCrossMarginPosition
  • cancelCrossMarginOrder
  • withdrawAccountKeeperBalance

Subgraph endpoint update required

Hey team,

We've noticed that you're referencing a subgraph deployed on The Graph's hosted service in this repository. Just a heads-up: after June 12th, hosted service subgraph endpoints will no longer be available as the offering is being deprecated.

If you are the subgraph owner or maintainer, it's time to upgrade your subgraph to the network. This ensures everything keeps running smoothly and you get access to all the latest features and improvements. Here is a quick guide with all the upgrade steps.

If you're not the subgraph owner or maintainer, check Graph Explorer to see if the subgraph development team has already upgraded to the network. If you don’t find an upgraded subgraph, a friendly nudge to the subgraph development team would be greatly appreciated—it's a quick process that benefits everyone. Here's the upgrade guide with all the necessary steps for the subgraph development team.

Once the subgraph is upgraded to the network, you can create an API key and updated query URL in Subgraph Studio then update this repository to query from the new endpoint, https://api.studio.thegraph.com/query/<ID>/<SUBGRAPH_NAME>/<VERSION>

Need more support or have more questions? Feel free to reach out to [email protected]. We're here to help!

Cheers,

Paka

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.