Git Product home page Git Product logo

pairswap's Introduction

Pairswap

Example

>>> from pairswap import ETHPair
>>>
>>> TEST_ADDRESS = '0x26fA8aac763B29AFBFEC7F23C85c1da57530781F'
>>> TEST_PRIVATE_KEY = '25954a23ff10562f3d7e34b55faaa920f04cd576380de04a52f187760db28e70'
>>> TEST_PROVIDER = 'wss://kovan.infura.io/ws/v3/ad54ae9fe2a694a99c62e8fb1fba244e'
>>> TEST_BONDLY = '0xde2005691855e2c71864828a531b47c4537659d4'
>>>
>>> pair = ETHPair(
...     address=TEST_ADDRESS,
...     private_key=TEST_PRIVATE_KEY,
...     provider=TEST_PROVIDER,
...     token=TEST_BONDLY,
... )
>>> pair.is_connected
True
>>> pair
<ETHPair(BONDLY)@0x7ff5f320da60>
>>> pair.balance
1.831966236171743
>>> pair.token_balance
119.63256903080517
>>> pair.weth_address
'0x5Ed806391C930321A89c29a1C0dCE237F30012f1'
>>> pair.price
348.0490514924989
>>> pair.token_price
0.001609960895976091
>>> pair.suggest_gas_price()
1800000000
>>> from web3 import Web3
>>> gas_price = Web3.toWei(1, 'gwei')
>>> pair.swap(0.05, gas=200000, gas_price=gas_price)
'0xbd7e8a9c7883ea8c72efa875d0e4466a705f798d81c7b4d2cbeab6461d24f8f4'
>>> pair.wait('0xbd7e8a9c7883ea8c72efa875d0e4466a705f798d81c7b4d2cbeab6461d24f8f4')
AttributeDict({'blockHash'...
>>> pair.balances
(1.781855709171742, 149.55144756540705)
>>> pair.wait(pair.unswap(50, gas=200000, gas_price=gas_price))
AttributeDict({'blockHash'...
>>> pair.balances
(1.862722511685864, 99.55144756540705)

pairswap's People

Contributors

anryko avatar

Stargazers

Andy avatar  avatar KE avatar

Watchers

James Cloos avatar

Forkers

bellyfat

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.